﻿namespace RabbitMQSample.WebApi.RabbitMQLibs
{
    public interface IRabbitMQShareProducerBase : IDisposable
    {
        /// <summary>
        /// 发布消息
        /// </summary>
        /// <param name="routingKey">路由key，当使用默认交换机或交换机类型为 Direct 时，默认可以与队列名保持一致</param>
        /// <param name="msg">消息</param>
        /// <param name="exchange">交换机</param>
        /// <param name="stoppingToken"></param>
        Task<bool> ProduceAsync(string routingKey, string msg, string exchange = "", CancellationToken stoppingToken = default);
        /// <summary>
        /// 发布消息（带消息确认）
        /// </summary>
        /// <param name="routingKey">路由key，当使用默认交换机或交换机类型为 Direct 时，默认可以与队列名保持一致</param>
        /// <param name="msg">消息</param>
        /// <param name="exchange">交换机</param>
        /// <param name="stoppingToken"></param>
        /// <returns>返回消息是否发送到 RabbitMQ</returns>
        Task<bool> ProduceWithConfirmAsync(string routingKey, string msg, string exchange = "", CancellationToken stoppingToken = default);
    }
}
